home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-27 | 3.0 KB | 124 lines | [TEXT/CWIE] |
- //
- // CQ3BoxesPane.cp
- //
- // class CQ3BoxesPane
- // A Pane for rendering 4 boxes in a QuickDraw 3D view.
- // Borrowed heavily from the "START HERE" sample code from Apple.
- //
- // by James Jennings
- // November 22, 1995
- //
-
- #include "CQ3BoxesPane.h"
- #include "C4BoxMaker.h" // defines the model
- #include "C3Lights.h" // defines the light group
- #include "CCameraMaker.h" // defines the camera
- #include "StQ3Disposer.h"
- #include "QD3D Debug Macros.h"
- #include <QD3DMath.h>
- #include <QD3DTransform.h>
-
- CQ3BoxesPane*
- CQ3BoxesPane::CreateQ3BoxesPaneStream(LStream *inStream)
- {
- return new CQ3BoxesPane(inStream);
- }
-
- CQ3BoxesPane::CQ3BoxesPane()
- { // default constructor
- // Does nothing. Must call FinishCreate() later.
- }
-
- CQ3BoxesPane::CQ3BoxesPane(const CQ3BoxesPane &inOriginal)
- : CQD3DPane(inOriginal)
- { // copy constructor
- mRotation = inOriginal.mRotation;
- StartIdling(); // start the periodical
- }
-
- CQ3BoxesPane::CQ3BoxesPane(LStream *inStream)
- : CQD3DPane(inStream)
- { // stream constructor
- // Does nothing. Must call FinishCreate() later.
- }
-
- CQ3BoxesPane::~CQ3BoxesPane()
- { // destructor
- }
-
- void
- CQ3BoxesPane::FinishCreateSelf()
- { // Inherit the other initialization.
- CQD3DPane::FinishCreateSelf();
-
- // set the rotation matrix to the identity matrix
- ::Q3Matrix4x4_SetIdentity(&mRotation);
-
- StartIdling(); // start the periodical
- }
-
- void
- CQ3BoxesPane::MakeCamera()
- { // Make and add a camera to the current view.
- SDimension16 frameSize;
- GetFrameSize(frameSize);
- CCameraMaker theCamera(frameSize); // construct a camera
- TQ3Status status = ::Q3View_SetCamera(mView, theCamera.Get());
- ThrowIfQ3Fail_(status);
- }
-
- void
- CQ3BoxesPane::MakeLightGroup()
- {
- C3Lights theLights;
- // add the lights to the group
- TQ3Status status = ::Q3View_SetLightGroup(mView, theLights.Get());
- ThrowIfQ3Fail_(status);
- }
-
- void
- CQ3BoxesPane::MakeModel()
- {
- // construct the model
- C4BoxMaker theBoxes;
- // get the model and store a reference to it.
- mModel = ::Q3Shared_GetReference(theBoxes.Get());
- ThrowIfNil_(mModel);
- }
-
- TQ3Status
- CQ3BoxesPane::SubmitScene()
- { // Submit the stuff we have in our scene.
- // Don't throw anything from inside this function, else
- // ::Q3View_EndRendering() never gets called.
- TQ3Status status;
- /* status = ::Q3Style_Submit( mInterpolation, mView );
- if (status==kQ3Failure) return status;
- status = ::Q3Style_Submit( mBackFacing, mView );
- if (status==kQ3Failure) return status;
- status = ::Q3Style_Submit( mFillStyle, mView );
- if (status==kQ3Failure) return status;*/
-
- // Do the inherited stuff (interpolation, backfacing, fillstyle)
- status = CQD3DPane::SubmitScene();
- if (status==kQ3Failure) return status;
- // Do the rotation.
- status = ::Q3MatrixTransform_Submit( &mRotation, mView );
- if (status==kQ3Failure) return status;
- // Do the model.
- status = ::Q3DisplayGroup_Submit( mModel, mView );
- return status;
- }
-
- void
- CQ3BoxesPane::SpendTime( const EventRecord &inMacEvent)
- { // on each null event, spin a little.
- TQ3Matrix4x4 tmp;
-
- ::Q3Matrix4x4_SetRotate_XYZ(&tmp, 0.1, 0.12, 0.08);
- ::Q3Matrix4x4_Multiply(&mRotation, &tmp, &mRotation);
-
- Refresh();
- }
-
-